﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonsterEngine.Interfaces;

namespace MonsterEngine.Managers
{
    public class LevelManager
    {
        public static void DetermineLevelBonus(IFightable winner, IFightable loser)
        {
            int winBonus = 2;
            int loseBonus = 1;
            Console.WriteLine("Awarding {0} with {1} for winning", winner.Name, winBonus);
            Console.WriteLine("Awarding {0} with {1} for losing", loser.Name, loseBonus);
            winner.Experience += 2;
            loser.Experience += 1;
            Console.WriteLine("{0} has {1} points of exp",winner.Name, winner.Experience);
            Console.WriteLine("{0} has {1} points of exp",loser.Name, loser.Experience);

            IsLeveledUp(winner);
            IsLeveledUp(loser);
        }

        private static void IsLeveledUp(IFightable player)
        {
            int threshHold = 5 * player.Level * (1 + player.Level); // 10 for first level, should be more in the end (testing)
            if (player.Experience >= threshHold)
            {
                player.Level += 1;
                Console.WriteLine("{0} has leveled up to {1}! Gratz!", player.Name, player.Level);
            }
        }

    }
}
